'use strict';
module.exports = (app) => {
  // 商品sku表
  const { STRING, INTEGER, FLOAT } = app.Sequelize;
  const Connect = app.model.define('s_connect', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },

    s_attributes_key_id: {
      type: INTEGER,
      comment: '商品主键id',
      unique: 'Connect',
    },
    s_sku_id: {
      type: INTEGER,
      comment: '规格id',
      unique: 'Connect',
    },
  });
  Connect.associate = function () {
    // 多对多关联表
    app.model.Tables.Shop.Sku.belongsToMany(
      app.model.Tables.Shop.AttributesKey,
      {
        through: {
          model: Connect,
          unique: 'false',
        },
        // foreignKey: "goods_id",
        // constraints: false,
      }
    );
    app.model.Tables.Shop.AttributesKey.belongsToMany(
      app.model.Tables.Shop.Sku,
      {
        through: {
          model: Connect,
          unique: false,
        },
        // foreignKey: "sku_id",
        // constraints: false,
      }
    );
  };
  return Connect;
};
